/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.eventos.bc;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.cip.esymons.eventos.be.DetalleConcepto;

/**
 *
 * @author oscar
 */
@Stateless
public class DetalleConceptoFacade implements DetalleConceptoFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(DetalleConcepto detalleConcepto) {
        em.persist(detalleConcepto);
    }

    public void edit(DetalleConcepto detalleConcepto) {
        em.merge(detalleConcepto);
    }

    public void remove(DetalleConcepto detalleConcepto) {
        em.remove(em.merge(detalleConcepto));
    }

    public DetalleConcepto find(Object id) {
        return em.find(DetalleConcepto.class, id);
    }

    public List<DetalleConcepto> findAll() {
        return em.createQuery("select object(o) from DetalleConcepto as o  where o.dcoEstado=true order by o.dcoNombre").getResultList();
    }

    public List<DetalleConcepto> listarxConcepto(int idTipoConcepto) {
         return em.createQuery("select object(o) from DetalleConcepto as o where o.tpcCodigo.tpcCodigo=?1").setParameter(1, idTipoConcepto).getResultList();
    }
 
}
